package com.rds.web.controller.pms;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.rds.common.annotation.Log;
import com.rds.common.enums.BusinessType;
import com.rds.system.domain.RdaState;
import com.rds.system.service.IRdaStateService;
import com.rds.common.core.controller.BaseController;
import com.rds.common.core.domain.AjaxResult;
import com.rds.common.utils.poi.ExcelUtil;
import com.rds.common.core.page.TableDataInfo;

/**
 * 策略状态Controller
 *
 * @author rds
 * @date 2021-05-05
 */
@RestController
@RequestMapping("/pms/state")
public class RdaStateController extends BaseController
{
    @Autowired
    private IRdaStateService rdaStateService;

    /**
     * 查询策略状态列表
     */
    @PreAuthorize("@ss.hasPermi('pms:policy:list')")
    @GetMapping("/list")
    public TableDataInfo list(RdaState rdaState)
    {
        startPage();
        List<RdaState> list = rdaStateService.selectRdaStateList(rdaState);
        return getDataTable(list);
    }

    /**
     * 导出策略状态列表
     */
    @PreAuthorize("@ss.hasPermi('pms:state:export')")
    @Log(title = "策略状态", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(RdaState rdaState)
    {
        List<RdaState> list = rdaStateService.selectRdaStateList(rdaState);
        ExcelUtil<RdaState> util = new ExcelUtil<RdaState>(RdaState.class);
        return util.exportExcel(list, "state");
    }

    /**
     * 获取策略状态详细信息
     */
    @PreAuthorize("@ss.hasPermi('pms:state:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(rdaStateService.selectRdaStateById(id));
    }

    /**
     * 新增策略状态
     */
    @PreAuthorize("@ss.hasPermi('pms:state:add')")
    @Log(title = "策略状态", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RdaState rdaState)
    {
        return toAjax(rdaStateService.insertRdaState(rdaState));
    }

    /**
     * 修改策略状态
     */
    @PreAuthorize("@ss.hasPermi('pms:state:edit')")
    @Log(title = "策略状态", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RdaState rdaState)
    {
        return toAjax(rdaStateService.updateRdaState(rdaState));
    }

    /**
     * 删除策略状态
     */
    @PreAuthorize("@ss.hasPermi('pms:state:remove')")
    @Log(title = "策略状态", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(rdaStateService.deleteRdaStateByIds(ids));
    }
}
